package com.pashanhoo.designpatterns.singleton;

/**双重检查-voliate防止重排序[推荐用]
 * @author 胡庆安
 * @version V1.0
 * @Package designpatterns.singleton
 * @date 2020/10/27 16:47
 * @Copyright © 2010-2020 爬山虎科技（扬州）股份有限公司
 */
public class DoubleCheckVoliateLazy {
    private static volatile DoubleCheckVoliateLazy singleton;

    private DoubleCheckVoliateLazy() {}

    public static DoubleCheckVoliateLazy getInstance() {
        if (singleton == null) {
            synchronized (DoubleCheckVoliateLazy.class) {
                if (singleton == null) {
                    singleton = new DoubleCheckVoliateLazy();
                }
            }
        }
        return singleton;
    }

}
